package com.ea.eadp.nexus.test.workflow.newconsole;

import org.openqa.selenium.WebDriver;

import com.ea.eadp.nexus.test.common.TestUtil;
import com.ea.eadp.nexus.test.pageDefinition.newconsole.WelcomePage;
import com.ea.eadp.nexus.test.workflow.WorkflowElement;
import com.ea.eadp.nexus.test.workflow.WorkflowElementArgument;

public class WelcomeWorkflowElement extends WorkflowElement {
    
    protected WelcomePage welcomePage;
    
    public String tokenId;
    public String deviceId;
    public boolean isgen4 = false;
    
    public WelcomeWorkflowElement(
        WebDriver driver, WorkflowElementArgument argument
    ) {
        super(driver, argument);
        welcomePage = new WelcomePage(driver);
    }
    
    @Override
    public String getDescription() {
        return "New console welcome page workflow";
    }
    
    @Override
    public void init() {
        String url = TestUtil.getConsole2ConnectUrl(
            args.clientId, tokenId, args.locale, args.country.name(), deviceId
        );
        if (isgen4) {
            url = url + "&isgen4=true";
        }
        welcomePage.navigate(url);
        welcomePage.waitPageLoadCompleted();
    }
    
    @Override
    public void doAction() {
        welcomePage.selectCheckBox(WelcomePage.acceptCheckBox);
    }
    
    @Override
    public void moveNext() {
        welcomePage.sendControllerKey('A');
    }
    
}
